#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;

class Solution {
public:
    static string compressString(string S)
    {
        string str = S;
        int count = 1, begin = 0;
        char ch = S[0];
        for (int i = 1; i < str.size(); i++)
        {
            if (str[i] == ch)
            {
                count++;
            }
            else
            {
                str.replace(begin + 1, count - 1, std::to_string(count).c_str());
                if (count == 1)
                    begin = i + 1;
                else
                    begin = i;
                ch = S[i];
                count = 1;
            }
        }
        if (S.size() < str.size())
            return S;
        else
            return str;
    }
};

int main()
{
    
    return 0;
}